package com.ymatou.iapi.livebuyer.testcase;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.livebuyer.parameter.QuerySellerLivesBean;
import com.ymatou.iapi.livebuyer.service.QuerySellerLivesCall;
import com.ymatou.iapi.liveseller.parameter.CreateSellerLiveBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
/**
*批量获取买手进行中的直播
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_QuerySellerLives{
	private static QuerySellerLivesBean querysellerlivesBean;
	private static QuerySellerLivesCall querysellerlivesCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("批量获取买手进行中的直播");
	}

	@Before
	public void caseUp() {
		querysellerlivesBean=new QuerySellerLivesBean();
		querysellerlivesCall=new QuerySellerLivesCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(querysellerlivesCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QuerySellerLives_001() {
		Logger.start(true,"批量获取买手进行中的直播成功");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			Integer sid=initcreatebean.getLiveDto().getUserId();
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			LiveRoomCallService.SellerLiveOnline(livedto.getId(), livedto.getUserId());
			List<Integer> sellerIdList=new ArrayList<Integer>();
			sellerIdList.add(sid);
			querysellerlivesBean.setSellerIdList(sellerIdList);
			querysellerlivesCall.setData(querysellerlivesBean);
			querysellerlivesCall.callService();			
			Logger.verifyEquals("200", querysellerlivesCall.getString("code"), "判断code");
			Logger.verifyEquals(1, querysellerlivesCall.getSellerLiveDto().size(), "验证露出数量");
			Logger.verifyEquals(livedto.getLiveTitle(), querysellerlivesCall.getSellerLiveDto().get(0).getLiveTitle(), "验证LiveTitle");
			Logger.verifyEquals(livedto.getUserId(), querysellerlivesCall.getSellerLiveDto().get(0).getUserId(), "验证UserId");
			Logger.verifyEquals(livedto.getId(), querysellerlivesCall.getSellerLiveDto().get(0).getLiveId(), "验证LiveId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_QuerySellerLives_002() {
		Logger.start(true,"不输入参数sellerIdList失败");
		try {
			querysellerlivesCall.setData(querysellerlivesBean);
			querysellerlivesCall.callService();			
			Logger.verifyEquals("100", querysellerlivesCall.getString("code"), "判断code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_QuerySellerLives_003() {
		Logger.start(true,"sellerId没有进行中直播返回空");
		try {
			List<Integer> sellerIdList=new ArrayList<Integer>();
			sellerIdList.add(1);
			querysellerlivesBean.setSellerIdList(sellerIdList);
			querysellerlivesCall.setData(querysellerlivesBean);
			querysellerlivesCall.callService();			
			Logger.verifyEquals("200", querysellerlivesCall.getString("code"), "判断code");
			Logger.verifyEquals(0, querysellerlivesCall.getSellerLiveDto().size(), "验证露出数量");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QuerySellerLives_004() {
		Logger.start(true,"批量获取买手进行中的直播，status为7不展示");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			Integer sid=initcreatebean.getLiveDto().getUserId();
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			new LiveRoomWapper().updateLiveRoomPushStatus(livedto.getId(), 7);
			List<Integer> sellerIdList=new ArrayList<Integer>();
			sellerIdList.add(sid);
			querysellerlivesBean.setSellerIdList(sellerIdList);
			querysellerlivesCall.setData(querysellerlivesBean);
			querysellerlivesCall.callService();			
			Logger.verifyEquals("200", querysellerlivesCall.getString("code"), "判断code");
			Logger.verifyEquals(0, querysellerlivesCall.getSellerLiveDto().size(), "验证露出数量");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QuerySellerLives_005() {
		Logger.start(true,"批量获取买手进行中的直播成功，status为3展示");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			Integer sid=initcreatebean.getLiveDto().getUserId();
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			new LiveRoomWapper().updateLiveRoomPushStatus(livedto.getId(), 3);
			List<Integer> sellerIdList=new ArrayList<Integer>();
			sellerIdList.add(sid);
			querysellerlivesBean.setSellerIdList(sellerIdList);
			querysellerlivesCall.setData(querysellerlivesBean);
			querysellerlivesCall.callService();			
			Logger.verifyEquals("200", querysellerlivesCall.getString("code"), "判断code");
			Logger.verifyEquals(1, querysellerlivesCall.getSellerLiveDto().size(), "验证露出数量");
			Logger.verifyEquals(livedto.getLiveTitle(), querysellerlivesCall.getSellerLiveDto().get(0).getLiveTitle(), "验证LiveTitle");
			Logger.verifyEquals(livedto.getUserId(), querysellerlivesCall.getSellerLiveDto().get(0).getUserId(), "验证UserId");
			Logger.verifyEquals(livedto.getId(), querysellerlivesCall.getSellerLiveDto().get(0).getLiveId(), "验证LiveId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QuerySellerLives_006() {
		Logger.start(true,"批量获取买手进行中的直播，status为8不展示");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			Integer sid=initcreatebean.getLiveDto().getUserId();
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			new LiveRoomWapper().updateLiveRoomPushStatus(livedto.getId(), 8);
			List<Integer> sellerIdList=new ArrayList<Integer>();
			sellerIdList.add(sid);
			querysellerlivesBean.setSellerIdList(sellerIdList);
			querysellerlivesCall.setData(querysellerlivesBean);
			querysellerlivesCall.callService();			
			Logger.verifyEquals("200", querysellerlivesCall.getString("code"), "判断code");
			Logger.verifyEquals(0, querysellerlivesCall.getSellerLiveDto().size(), "验证露出数量");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QuerySellerLives_007() {
		Logger.start(true,"批量获取买手进行中的直播，status为9不展示");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			Integer sid=initcreatebean.getLiveDto().getUserId();
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			new LiveRoomWapper().updateLiveRoomPushStatus(livedto.getId(), 9);
			List<Integer> sellerIdList=new ArrayList<Integer>();
			sellerIdList.add(sid);
			querysellerlivesBean.setSellerIdList(sellerIdList);
			querysellerlivesCall.setData(querysellerlivesBean);
			querysellerlivesCall.callService();			
			Logger.verifyEquals("200", querysellerlivesCall.getString("code"), "判断code");
			Logger.verifyEquals(0, querysellerlivesCall.getSellerLiveDto().size(), "验证露出数量");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QuerySellerLives_008() {
		Logger.start(true,"批量获取买手进行中的直播，status为10不展示");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			Integer sid=initcreatebean.getLiveDto().getUserId();
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			new LiveRoomWapper().updateLiveRoomPushStatus(livedto.getId(), 10);
			List<Integer> sellerIdList=new ArrayList<Integer>();
			sellerIdList.add(sid);
			querysellerlivesBean.setSellerIdList(sellerIdList);
			querysellerlivesCall.setData(querysellerlivesBean);
			querysellerlivesCall.callService();			
			Logger.verifyEquals("200", querysellerlivesCall.getString("code"), "判断code");
			Logger.verifyEquals(0, querysellerlivesCall.getSellerLiveDto().size(), "验证露出数量");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QuerySellerLives_009() {
		Logger.start(true,"批量获取买手进行中的直播，未开始不展示");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			Integer sid=initcreatebean.getLiveDto().getUserId();
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			List<Integer> sellerIdList=new ArrayList<Integer>();
			sellerIdList.add(sid);
			querysellerlivesBean.setSellerIdList(sellerIdList);
			querysellerlivesCall.setData(querysellerlivesBean);
			querysellerlivesCall.callService();			
			Logger.verifyEquals("200", querysellerlivesCall.getString("code"), "判断code");
			Logger.verifyEquals(0, querysellerlivesCall.getSellerLiveDto().size(), "验证露出数量");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}